<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>对象的结构赋值</title>
</head>
<body>
  <script>
    const obj = {name: '孙悟空', age: 18, gender: '男'}
    let {name, age, gender} = obj
    console.log(name,age, gender) // 孙悟空 18 男
    /*
      给变量起别名，将obj中name属性赋值给变量a,将age属性赋值给变量b......
      加默认值，如果对象中有该属性，则取对象中的属性值，否则使用默认值
    */
    let {name: a, age: b, gender:c = '女', address = '花果山'} = obj
    console.log(a, b, c, address) // 孙悟空 18 男 花果山

  </script>
</body>
</html>